<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="login/css/index.css"/>
		<style type="text/css">
			/*body{
               background: url(img/4.jpg) no-repeat;
            }*/

		</style>
	</head>
	<script src="jquery/jquery-3.5.1.js"></script>
	<body>
		<div class="bg">
			<div class="wel">学籍预警系统管理(学生)</div>
	        <div class="user">
	       	    <div style="">学号</div>
	       	    <input  type="text" name="用户"  placeholder="输入学号" id="xueHao" />
	        </div>
	        <div class="password" >
	        	<div>密&nbsp;&nbsp;&nbsp;码</div>
	       	    <input class="" type="password" name="密码" id="miMa" />
	        </div>
	        <div class="rem" >
	       	  <input type="checkbox" name="" id="" value="" />
	        	 <div id="reb">
	        	 	记住密码
	        	 </div>
	        </div>
	        <div class="fg" >
	       	    <div style="font-size: 11px;margin-top: 11px;">
	       	    	<a style="font-size: 11px;" href="/login2.html">老师登录？</a>
	       	    </div>
	        </div>
	        <input class="btn" type="button" id="loginButton" name="登录" value="学生登录" /><br/>
		</div>
	</body>

	<script>
		$(function () {
			$("#loginButton").click(function () {
				// var xueHao = $("#xueHao").val();
				// var miMa = $("#miMa").val();
				$.ajax({   // 异步请求   想象成线程状态
					url:"/xueSheng/login",   // 请求路径
					type:"post",               // 请求的方式，不区分大小写   传递json不能使用get请求，否则返回400错误
					contentType:"application/json;charset=utf-8",
					datatype:"text",
					data:JSON.stringify({
						            xueHao:$("#xueHao").val(),
						              miMa:$("#miMa").val()
						        }),
					success:function(response){                        // 后台服务响应成功，自动返回数据
						if(response.code === 200) {
							alert(response.msg);
							alert(response.yongHu.xingMing);
							// sessionStorage只支持字符串存放
							sessionStorage.setItem("yongHu", JSON.stringify(response.yongHu));
							window.location.href="guanliyuan_chengjiguanli.html";
						}
						else {
							alert(response.msg);
						}
					},
					error:function(response){             // 网络请求失败，自动调用此方法
						console.log("出错" + response);
					}
				});
			});
		});
	</script>
</html>
